package com.itheima.practice;

import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeSet;

public class TreeSetPractice {
    public static void main(String[] args) {
        TreeSet<Person> ts = new TreeSet<>((o1, o2) -> (int) (o2.getMath()+o2.getChinese()+o2.getEnglish()-o1.getMath()-o1.getChinese()-o1.getEnglish()));
        Scanner scanner = new Scanner(System.in);//键盘输入流

        for(int i=0;i<3;i++){
            System.out.println("输入第"+(i+1)+"个学生信息：");
            System.out.println("请输入姓名：");
            //录入无空格
            String name = scanner.next();
            System.out.println("请输入语文成绩：");
            double chinese = scanner.nextDouble();
            System.out.println("请输入数学成绩：");
            double math = scanner.nextDouble();
            System.out.println("请输入英语成绩：");
            double english = scanner.nextDouble();
            //创建Person对象
            Person person = new Person(name, chinese, math, english);
            ts.add(person);
        }
        //遍历集合
        for(Person person:ts){
            System.out.println(person);
        }
    }
}
